package com.adv.controller;

import java.util.concurrent.TimeUnit;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.adv.controller.base.BaseController;

@Controller
public class RedisTestController extends BaseController {
	@Autowired
	private RedisTemplate<String, String> redisTemplate;

	@ResponseBody
	@RequestMapping("/redis/test")
	@RequiresRoles("user_admin")
	public Object detail(ModelMap model) throws Exception {
		String key = "hello", value = "world";
		redisTemplate.opsForValue().set(key, value, 3, TimeUnit.SECONDS);
		System.out.println(redisTemplate.opsForValue().get(key));
		return redisTemplate.opsForValue().get(key);
		// return "hello world";
	}
}
